package com.mysterymall.Controller.Admin;

import com.mysterymall.Common.Comp.Log;
import com.mysterymall.Common.Utils.Result;
import com.mysterymall.Model.Dto.SlideshowDto;
import com.mysterymall.Service.SlideshowService;
import org.springframework.web.bind.annotation.*;

/**
 * 轮播图
 * @ClassName com.mysterymall.Controller.Admin
 * @Description
 * @Author HuangWX
 * @Time 2023/11/17  18:18
 */
@RestController
@RequestMapping("/slideshow")
public class AdminSlideshowCont {


    private final SlideshowService slideshowService;


    /**
     * 构造器注入
     * @param slideshowService 轮播图服务
     */
    public AdminSlideshowCont(SlideshowService slideshowService) {
        this.slideshowService = slideshowService;
    }

    /**
     * 获取轮播图
     * @return Result
     */
    @GetMapping("/getSlideshow")
    @Log
    public Result getSlideshow(){
        return slideshowService.getSlideshow();
    }


    /**
     * 新增轮播图
     * @param slideshowDto 轮播图dto
     * @return Result
     */
    @PostMapping("/addSlideshow")
    @Log
    public Result addSlideshow(@RequestBody SlideshowDto slideshowDto){
        return slideshowService.addSlideshow(slideshowDto);
    }


    /**
     * 修改轮播图
     * @param slideshowDto 轮播图dto
     * @return Result
     */
    @PostMapping("/updateSlideshow")
    @Log
    public Result updateSlideshow(@RequestBody SlideshowDto slideshowDto){
        return slideshowService.updateSlideshow(slideshowDto);
    }
}
